namespace DuToanT2.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class GiaThongBao : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.GiaThongBao_ChiTiet",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Value = c.Double(nullable: false),
                        GiaThongBaoId = c.Int(nullable: false),
                        VatTuId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.GiaThongBao", t => t.GiaThongBaoId, cascadeDelete: true)
                .ForeignKey("dbo.VatTu", t => t.VatTuId, cascadeDelete: true)
                .Index(t => t.GiaThongBaoId)
                .Index(t => t.VatTuId);
            
            CreateTable(
                "dbo.GiaThongBao",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 150),
                        ToanVan = c.String(),
                        ThoiDiemCongBo = c.DateTime(),
                        CityId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.City", t => t.CityId, cascadeDelete: true)
                .Index(t => t.CityId);
            
            CreateTable(
                "dbo.City",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.GiaThongBao_ApDung",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        UuTien = c.Int(nullable: false),
                        GiaThongBaoId = c.Int(nullable: false),
                        HangMuc_CongViecId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.GiaThongBao", t => t.GiaThongBaoId, cascadeDelete: true)
                .ForeignKey("dbo.HangMuc_CongViec", t => t.HangMuc_CongViecId, cascadeDelete: true)
                .Index(t => t.GiaThongBaoId)
                .Index(t => t.HangMuc_CongViecId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.GiaThongBao_ApDung", new[] { "HangMuc_CongViecId" });
            DropIndex("dbo.GiaThongBao_ApDung", new[] { "GiaThongBaoId" });
            DropIndex("dbo.GiaThongBao", new[] { "CityId" });
            DropIndex("dbo.GiaThongBao_ChiTiet", new[] { "VatTuId" });
            DropIndex("dbo.GiaThongBao_ChiTiet", new[] { "GiaThongBaoId" });
            DropForeignKey("dbo.GiaThongBao_ApDung", "HangMuc_CongViecId", "dbo.HangMuc_CongViec");
            DropForeignKey("dbo.GiaThongBao_ApDung", "GiaThongBaoId", "dbo.GiaThongBao");
            DropForeignKey("dbo.GiaThongBao", "CityId", "dbo.City");
            DropForeignKey("dbo.GiaThongBao_ChiTiet", "VatTuId", "dbo.VatTu");
            DropForeignKey("dbo.GiaThongBao_ChiTiet", "GiaThongBaoId", "dbo.GiaThongBao");
            DropTable("dbo.GiaThongBao_ApDung");
            DropTable("dbo.City");
            DropTable("dbo.GiaThongBao");
            DropTable("dbo.GiaThongBao_ChiTiet");
        }
    }
}
